Ext.define('PJ.view.setassessmentpaper.SelectStaffRightFrame', {
    extend: 'AM.default.DefaultWindowForm',
    
    alias: ['widget.selectStaffRightFrame'],
    
    requires: ['PJ.view.setassessmentpaper.PreSelectStaffList', 'PJ.view.setassessmentpaper.ChooseSelectStaffList'],
    
    modal: true,// 开启不允许点击其他组件
    frame: true,
    notEdit: true,
    width: 735,
    height: 560,
    isSame: false,
    isEdit: null,
    
    initComponent: function(){
    	var me = this;
    	me.items= [{
    		xtype: "fieldset",
    		layout: 'column',
            collapsible: false, //显示三角
            defaults: {
    			xtype: 'textfield',
            	labelAlign: 'right',
            	labelWidth: 85,
            	readOnly: false,
//            	fieldCls: 'noBorder',
            	columnWidth: .45
            },
    		items: [ /*{
				xtype: 'textfield',
				fieldLabel:'评估开始时间',
				name: 'assessStartDay',
				readOnly: true,
				fieldCls:"noBorder",
				margin: '5 0 0 0'
			}, {
				xtype: 'textfield',
				fieldLabel: '评估结束时间',
				name: 'assessEndDay',
				readOnly: true,
				fieldCls:"noBorder",
				margin: '5 0 0 0'
			}, */{
				xtype: 'defaultDate',
				fieldLabel: '评估开始时间',
				name: 'assessStartDay',
				id: 'assessStartTime',
				vtype: 'startLessEndDate',
				startLessEndDate: {
					targetCmpId: 'assessEndTime',
					isStart: true
				},
				emptyText: "请输入评估开始时间"
			}, {
				xtype: 'defaultDate',
				fieldLabel: '评估结束时间',
				name: 'assessEndDay',
				id: 'assessEndTime',
				vtype: 'startLessEndDate',
				vtypeText: '结束时间不能早于开始时间！',
				startLessEndDate: {
					targetCmpId: 'assessStartTime',
					isStart: false
				},
				emptyText: "请输入结业时间"
			},{
				xtype: 'button',
				text: '保存',
            	columnWidth: .1,
				margin: '0 0 0 5',
				handler: function(){
			    	var form = me.down('form');
			    	var baseForm = form.getForm();
			    	if (!baseForm.isValid()) {
			    		return;
			    	}else{
			    		var assessStartTime = Ext.getCmp("assessStartTime").getValue();
						var assessEndTime = Ext.getCmp("assessEndTime").getValue();
						assessStartTime = Ext.Date.format(assessStartTime,'Y-m-d');
						assessEndTime = Ext.Date.format(assessEndTime,'Y-m-d');
						Ext.Ajax.request({
	            			url: me.grid.store.submitTimeUrl,
	            			params: {
	            				assessStartDay: assessStartTime,
	            				assessEndDay: assessEndTime,
	            				classId: me.classId
	            			},
	            			success: function(response){
	            				var data = response.responseText;
	            				var json = Ext.decode(data, true);
	            				if (json.success) {
	            					Ext.Msg.alert("信息", json.msg, function(){});
	            				}
	            				else {
	            					Ext.Msg.alert("信息", json.msg, function(){});
	            				}
	            			}
	            		});
			    	}
				}
			}/*{
    			xtype: "numberfield",
    			fieldLabel: '培训班结束前',
    			allowDecimals: false,//不允许输入小数
    			hideTrigger: true, // 控件微调整
    			name: 'assessStartDay',
            	columnWidth: .25,
    			regex: /^\d{1,3}$/,
    			regexText: '最大输入3位正整数！',
    			listeners: {
                    blur: function(item){
                    	var form = me.down("form");
                    	var baseForm = form.getForm();
                    	var startValue = item.getValue()
                    	var endValue = baseForm.findField("assessEndDay").getValue()
                    	if(startValue==""||startValue==null){
                    		baseForm.findField("assessStartDay").allowBlank=false;
                    	}else if(endValue==""||endValue==null){
                    		baseForm.findField("assessEndDay").allowBlank=false;
                    	}
                    	if((startValue==""||startValue==null)&&(endValue==""||endValue==null)){
                    		baseForm.findField("assessStartDay").allowBlank=true;
                    		baseForm.findField("assessEndDay").allowBlank=true;
                    	}
                    }
                }
    		},{
                xtype: 'label',
                html: '天，',
                padding:"3 0 0 3",
                columnWidth: .05
            },{
            	xtype: "numberfield",
    			fieldLabel: '结束后',
    			labelAlign: 'left',
    			allowDecimals: false,//不允许输入小数
    			hideTrigger: true, // 控件微调整
    			labelWidth: 43,
    			name: 'assessEndDay',
            	columnWidth: .2,
    			regex: /^\d{1,3}$/,
    			regexText: '最大输入3位正整数！',
    			listeners: {
                    blur: function(item){
                    	var form = me.down("form");
                    	var baseForm = form.getForm();
                    	var endValue = item.getValue()
                    	var startValue = baseForm.findField("assessStartDay").getValue()
                    	if(endValue==""||endValue==null){
                    		baseForm.findField("assessEndDay").allowBlank=false;
                    	}else if(startValue==""||startValue==null){
                    		baseForm.findField("assessEndDay").allowBlank=false;
                    	}
                    	if((startValue==""||startValue==null)&&(endValue==""||endValue==null)){
                    		baseForm.findField("assessStartDay").allowBlank=true;
                    		baseForm.findField("assessEndDay").allowBlank=true;
                    	}
                    }
                }
    		},{
                xtype: 'label',
                html: '天',
                padding:"3 0 0 3",
                columnWidth: .05
            }*/]
    	},{
    		xtype: "fieldset",
    		layout: 'column',
    		autoScroll: true,//可显示滚动条
            collapsible: false, //显示三角
            height:430,
    		items: [{
    	        xtype: "preSelectStaffList",
    	        columnWidth:1,
    	        height: 200
    	    }, {
    	        xtype: "chooseSelectStaffList",
    	        columnWidth: 1,
    	        height: 200
    	    }]
    	}/*,{
    		xtype: "container",
    		layout: 'column',
    		autoScroll: true,//可显示滚动条
            collapsible: false, //显示三角
            height:480,
    		items: [{
    	        xtype: "preSelectStaffList",
    	        columnWidth:1,
    	        height: 300
    	    }, {
    	        xtype: "chooseSelectStaffList",
    	        columnWidth: 1,
    	        height: 300
    	    }]
    	}*/];
    	me.buttons = [{
            text: '关闭',
            scope: this,
            handler: this.close
        }];
        me.callParent(arguments);
    },
    listeners: {
    	close: function(){
    		this.grid.store.load();
    	}
    }
});
